#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#include "stdio.h"
#include "string.h"
#include "stdlib.h"

char * myfgets(char *mybuf, int nMax, FILE *fp)
{

	if (fp == NULL)
	{
		return NULL;
	}
	strcpy(mybuf, "aaaaa");
	
	//
	return mybuf;
}

int main()
{
	int i = 0;
	FILE *fp = NULL;
	char buf[100];
	char *p = NULL;

	//char *fname2 = "/Users/lianghuang/git/heima_c/day6/src/demo02/test.txt";
	
	char *fname2 = "test.txt";
	fp = fopen(fname2, "r"); //不管文件是否存在，新建文件
	if (NULL == fp)
	{
		printf("func fopen() err\n");
		return -1;
	}

	while (!feof(fp))
	{
		//_cdecl fgets(_Out_z_cap_(_MaxCount) char * _Buf, _In_ int _MaxCount, _Inout_ FILE * _File);
		p = fgets(buf, 100, fp);
		if (p == NULL)
		{
			printf("func fgets() .....\n");
			return -1 ;
		}
		printf("%s \n", buf);
		printf("%s \n", p); 
	}

	
	if (fp != NULL)
	{
		fclose(fp);
		fp = NULL;
	}


	return 0;
}